Namespacing everything to /UVa.
[andmenj-acm.git] / UVa / 10298 - Power Strings / D.cpp
blobaa55712604172720d52ed85c31e8e5d9bcf8378c
1 #include <cstdio>
2 #include <cstring>
4 char s[2000002];
6 main(){
7 while (gets(s) && strcmp(s,".")) {
8 int n = strlen(s), m = n;
9 for (int i=2; i<=n; i++) {
10 while (n % i == 0) {
11 n /= i;
13 int j;
14 for (j=0; j < m-m/i && s[j] == s[j+m/i]; j++);
16 if (j == m-m/i) m /= i;
17 printf("End of iteration with i = %d: n = %d, m = %d\n", i, n, m);
20 printf("%lu\n",strlen(s)/m);